/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "绘制命令缓存.h"

#include "S_Vk帧缓存.h"


/*void f_记录命令缓存(S_Vk逻辑设备& 设备, VkPipeline& 线管, S_Vk顶点输入& 顶点输入)
{
	设备.m_命令缓存.resize(设备.m_交换链帧缓存.size());



	VkCommandBufferAllocateInfo allocInfo = {};
	allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
	allocInfo.commandPool = 设备.m_命令缓存池[0];
	allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
	allocInfo.commandBufferCount = (uint32_t)设备.m_命令缓存.size();



	if (vkAllocateCommandBuffers(设备.m_Device, &allocInfo, 设备.m_命令缓存.data()) != VK_SUCCESS) {
		throw std::runtime_error("failed to allocate command buffers!");
	}


	

	for (size_t i = 0; i < 设备.m_命令缓存.size(); i++) {
		S_Vk帧缓存& frame = *(S_Vk帧缓存*)设备.m_交换链帧缓存[i];

		VkCommandBufferBeginInfo beginInfo = {};
		beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
		beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;

		vkBeginCommandBuffer(设备.m_命令缓存[i], &beginInfo);

		VkRenderPassBeginInfo renderPassInfo = {};
		renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
		renderPassInfo.renderPass = 设备.m_渲染过程;
		renderPassInfo.framebuffer = frame.m_帧缓存[0];
		renderPassInfo.renderArea.offset = { 0, 0 };
		renderPassInfo.renderArea.extent = 设备.m_视口大小;

		VkClearValue clearValues[2] = {};
		clearValues[0].color = { 1.0f, 0.0f, 0.0f, 1.0f };
		clearValues[1].depthStencil = { 1.0f, 0 };

		renderPassInfo.clearValueCount = 2;
		renderPassInfo.pClearValues = clearValues;



		vkCmdBeginRenderPass(设备.m_命令缓存[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);

		{
			vkCmdBindPipeline(设备.m_命令缓存[i], VK_PIPELINE_BIND_POINT_GRAPHICS, 线管);

			{
				
			}
			
			vkCmdEndRenderPass(设备.m_命令缓存[i]);

		}
		

		if (vkEndCommandBuffer(设备.m_命令缓存[i]) != VK_SUCCESS) {
			throw std::runtime_error("failed to record command buffer!");
		}
	}


}*/





